package jqueryadmin;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;

public class Activator implements BundleActivator {

	private MainServlet ms;
	private HttpService service;
	
	public void start(BundleContext context) throws Exception {
		ServiceReference sRef = context.getServiceReference(HttpService.class
				.getName());
		if (sRef != null) {
			service = (HttpService) context.getService(sRef);
			service.registerResources("/registry/css", "/css", null);
			service.registerResources("/registry/js", "/js", null);
			service.registerResources("/registry/jQuery-admin.html", "/registry/jQuery-admin.html", null);
			ms = new MainServlet();
			service.registerServlet("/registry/jQuery-admin", ms, null, null);						
		}
	}
	
	public void stop(BundleContext context) throws Exception {
		service.unregister("/registry/jQuery-admin");
		service.unregister("/registry/css");
		service.unregister("/registry/js");
		service.unregister("/registry/jQuery-admin.html");
	}
}
